package com.listen.task;

import java.util.List;
import java.util.Map;

import com.listen.model.User;
import com.listen.model.UserCriteria;
import com.listen.service.UserService;
import com.listen.service.DB.ShuiliServiceImpl;

public class ShuiliTask implements Runnable {

	private UserService userService = null;
	public ShuiliTask (UserService userService){
		this.userService = userService;
	}
	
	@Override
	public void run() {
		/*UserCriteria criteria = new UserCriteria();
		criteria.createCriteria().andZyEqualTo("SL").andStatusLessThan(2).andTypeEqualTo(4);*/
		User u = new User();
		u.setType(4);
		u.setZy("SL");
        List<User> userList = userService.selectByUser(u);
        for(User user : userList) {
        	user.setAddress("http://www.sljls.cn/");
        	ShuiliServiceImpl shuili = new ShuiliServiceImpl();
        	Map<String,Object> map = shuili.lisetn(user, null);
        	int status = (int) map.get("successFlag");
        	int nowNum = (int) map.get("nowNum");
        	if(status == 1 && nowNum == user.getNowNum()) {
        		User usr = new User();
        		usr.setId(user.getId());
        		usr.setNowNum(15);
        		usr.setStatus(3);
        		userService.updateSelective(usr);
        	}
        }
	}
}
